package main

import (
	"github.com/astaxie/beego"
	"github.com/sirupsen/logrus"

	"learn-otp/config"
	"learn-otp/filter"

	_ "learn-otp/dao"
	_ "learn-otp/routers"
)

func main() {
	setLogLevel()

	beego.SetViewsPath("views")
	beego.SetStaticPath("/static", "views/static")

	beego.InsertFilter("/*", beego.BeforeRouter, filter.UserFilter)

	beego.Run()
}

func setLogLevel() {
	logLevel, err := logrus.ParseLevel(config.LogLevel)
	if err != nil {
		logLevel = logrus.InfoLevel
	}
	logrus.SetLevel(logLevel)
}
